Skip to main content

Minimum Number of Arrows to Burst Balloons

Question

None

Example 1
Input: [[10,16], [2,8], [1,6], [7,12]]
Output: 2

Solution

all//Minimum Number of Arrows to Burst Balloons.py


def findMinArrowShots(points):
if not points:
return 0
points.sort(key=lambda x: x[1])
res = 1
arrow = points[0][1]
for i in range(1, len(points)):
if points[i][0] > arrow:
res += 1
arrow = points[i][1]
return res